package com.example.scgw.benchmark.route;

import org.springframework.beans.BeanUtils;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * @author Aaron
 */
@Document
public class MongoRouteDefinition extends RouteDefinition {

  @Id
  private String id;

  @Override
  public String getId() {
    return this.id;
  }

  @Override
  public void setId(String id) {
    this.id = id;
  }

  @Override
  public String toString() {
    return "MongoRouteDefinition{" + "id='" + this.id + '\'' + ", predicates=" + getPredicates()
        + ", filters=" + getFilters()
        + ", uri=" + getUri() + ", order=" + getOrder() + ", metadata=" + getMetadata() + '}';
  }

  public static MongoRouteDefinition from(RouteDefinition route) {
    MongoRouteDefinition newRoute = new MongoRouteDefinition();
    BeanUtils.copyProperties(route, newRoute);
    return newRoute;
  }

}
